#include "connector.h"
#include "loger.h"
#include  "connection.h"
Connector::Connector(uint16_t port,QObject * parent):QTcpServer (parent)
{
    this->port = port;
}
Connector::~Connector()
{
    QString s("连接器connector已析构");
    Loger::info(s);
}
/**
 * 新的连接到达自动调用该函数
 * @brief incomingConnection
 * @param handle
 */
void Connector::incomingConnection(qintptr handle)
{
    Connection * connection = new Connection(handle, this);
    //发信号
    emit newConnection(connection);
}

/**
 * 开始监听
 * @brief startListen
 * @return
 */
bool Connector::startListen()
{
    //监听本机ip和端口
    return listen(QHostAddress::Any, this->port);
}
